package ui.noti

import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import com.example.mynewsapp.BuildConfig
import com.example.mynewsapp.R


/** ref link: this work as well
 * https://github.com/navczydev/NotificationPermissionAndroid13/blob/master/app/src/main/java/com/example/myapplication/NOTIFICATION_CHANNEL_ID.kt
 */
// com.example.mynewsapp.channel
const val NOTIFICATION_CHANNEL_ID = BuildConfig.APPLICATION_ID + ".channel"

@Deprecated(message = "Use Notify Lib Now")
fun sendNotification(context: Context) {
    val notificationManager = context
        .getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
    // We need to create a NotificationChannel associated with our CHANNEL_ID before sending a notification.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
        notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID) == null
    ) {
        val name = context.getString(R.string.app_name)
        val channel = NotificationChannel(
            NOTIFICATION_CHANNEL_ID,
            name,
            NotificationManager.IMPORTANCE_DEFAULT
        )
        notificationManager.createNotificationChannel(channel)
    }

    /**
     * ... the reset code
     */
}

private fun getUniqueId() = ((System.currentTimeMillis() % 10000).toInt())